<?php
class Hospital extends AppModel {
    var $name = 'Hospital';
    
    var $useTable='posts';
    
    var $order='Hospital.created DESC';
    
    
    /*var $hasMany = array('Comment'=>array(
        'conditions'=>array('Comment.status'=>array('published','locked'))
    ));
    */
    
    var $actsAs = array('Containable');
    
    var $belongsTo = array(
        'Category' => array(
            'className' => 'Category',
            'counterCache' => true,
            'counterScope' => array('Hospital.status' => 'published'),
        ),
        'District' => array(
            'className' => 'District',
            'counterCache' => true,
            'counterScope' => array('Hospital.status' => 'published'),
        ),
        'User'
    
    );
    
    
    
    
    
    /*var $validate = array(
        
        'name' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'required' => true,
                'message' => 'this field is required!'
            ),
            
        ),
        'address' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'required' => true,
                'message' => 'this field is required!'
            ),
            
        ),
        'phone' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'required' => true,
                'message' => 'this field is required!'
            ),
            
        ),
        
              
    );*/
    
    
    /*function beforeSave() {
        if(!empty($this->data['Hospital']['district'])) :
                $_district = strtolower(trim($this->data['Hospital']['district']));
                if ($_district) :
                    $this->District->recursive = -1;
                    $district = $this->District->find(array('name'=>$_district));
                    if (!$district) :
                        $this->District->create();
                        $district = $this->District->save(array('name'=>$_district));
                        $district['District']['id'] = $this->District->id;
                        if(!$district) :
                            $this->_flash(sprintf('The District %s could not be saved.',$_district));
                        endif;
                    endif;
                    if ($district) :
                        $this->data['Hospital']['district_id'] = $district['District']['id'];
                    endif;
                endif;
            
        endif;
        
        return true;
    }*/
    
    
    
    
}    
?>